package com.ly.web.controller.erp;

import com.ly.common.PageParam;
import com.ly.common.annotation.Log;
import com.ly.common.core.domain.AjaxResult;
import com.ly.common.enums.BusinessType;
import com.ly.common.utils.StringUtils;
import com.ly.heart.domain.KingInvoiceReceivableOtherEntity;
import com.ly.heart.domain.dto.KingInvoiceReceivableOtherDto;
import com.ly.heart.service.IKingInvoiceReceivableOtherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: Wuzh
 * @Description:
 * @Date Created in 19:27 2024-09-01
 * @return
 */
@Api (value = "KingInvoiceReceivableOther", tags = "其他应收单")
@RestController
@RequestMapping ("/heart/KingInvoiceReceivableOther")
public class KingInvoiceReceivableOtherController {

    @Resource
    private IKingInvoiceReceivableOtherService iKingInvoiceReceivableOtherService;

    @PreAuthorize ("@ss.hasPermi('heart:KingInvoiceReceivableOther:list')")
    @GetMapping ("/list")
    @ApiOperation ("其他应收单列表")
    @Log (title = "其他应收单列表")
    public AjaxResult list (KingInvoiceReceivableOtherEntity kingInvoiceReceivableOtherEntity) {
        List<KingInvoiceReceivableOtherEntity> kingInvoiceReceivableOtherEntities = iKingInvoiceReceivableOtherService.selectKingInvoiceReceivableOtherEntityList ( kingInvoiceReceivableOtherEntity );
        Integer count = iKingInvoiceReceivableOtherService.queryCount ( kingInvoiceReceivableOtherEntity );
        PageParam p = new PageParam ();
        p.setRecords ( kingInvoiceReceivableOtherEntities ).setTotal ( count );
        return AjaxResult.success ( p );
    }

    @PreAuthorize ("@ss.hasPermi('heart:KingInvoiceReceivableOther:query')")
    @GetMapping (value = "/{id}")
    @ApiOperation ("其他应收单列表详细信息")
    public AjaxResult getInfo (@PathVariable ("id") String id) {
        return AjaxResult.success ( iKingInvoiceReceivableOtherService.selectKingInvoiceReceivableOtherEntityById ( id ) );
    }

    @PreAuthorize ("@ss.hasPermi('heart:KingInvoiceReceivableOther:add')")
    @Log (title = "暂存其他应收单", businessType = BusinessType.INSERT)
    @PostMapping ("draft")
    @ApiOperation ("暂存其他应收单")
    public AjaxResult draft (@RequestBody KingInvoiceReceivableOtherDto kingInvoiceReceivableOtherDto) {
        KingInvoiceReceivableOtherEntity kingInvoiceReceivableOtherEntity = kingInvoiceReceivableOtherDto.getKingInvoiceReceivableOtherEntity ();
        if ( StringUtils.isNotBlank ( kingInvoiceReceivableOtherEntity.getId () ) ) {
            return iKingInvoiceReceivableOtherService.updateKingInvoiceReceivableOtherEntity ( kingInvoiceReceivableOtherDto );
        }
        return iKingInvoiceReceivableOtherService.draft ( kingInvoiceReceivableOtherDto );
    }

    @PreAuthorize ("@ss.hasPermi('heart:KingInvoiceReceivableOther:add')")
    @Log (title = "提交其他应收单", businessType = BusinessType.INSERT)
    @PostMapping ("submit")
    @ApiOperation ("提交其他应收单")
    public AjaxResult submit (@RequestBody KingInvoiceReceivableOtherEntity kingInvoiceReceivableOtherEntity) {
        AjaxResult submit = iKingInvoiceReceivableOtherService.submit ( kingInvoiceReceivableOtherEntity );
        return submit;
    }

    @PreAuthorize ("@ss.hasPermi('heart:KingInvoiceReceivableOther:edit')")
    @Log (title = "修改其他应收单", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation ("修改其他应收单")
    public AjaxResult edit (@RequestBody KingInvoiceReceivableOtherDto kingInvoiceReceivableOtherDto) {
        return iKingInvoiceReceivableOtherService.updateKingInvoiceReceivableOtherEntity ( kingInvoiceReceivableOtherDto );
    }

    @PreAuthorize ("@ss.hasPermi('heart:KingInvoiceReceivableOther:remove')")
    @Log (title = "删除其他应收单", businessType = BusinessType.DELETE)
    @DeleteMapping ("/{ids}")
    @ApiOperation ("删除其他应收单")
    public AjaxResult remove (@PathVariable String[] ids) {

        return iKingInvoiceReceivableOtherService.deleteKingInvoiceReceivableOtherEntityByIds ( ids );
    }

    @Log (title = "推送其他应收单")
    @GetMapping ("/send/{id}")
    @ApiOperation ("推送其他应收单")
    public AjaxResult send (@PathVariable String id) {

        return AjaxResult.success ( "推送成功" );
    }

    @Log ( title = "收款单选单，选择其他应收单" )
    @GetMapping ( "queryList" )
    @ApiOperation ( "收款单选单，选择其他应收单" )
    public AjaxResult queryList ( KingInvoiceReceivableOtherEntity kingInvoiceReceivableOtherEntity ) {

        return null;
    }

}
